pub fn convert_base(num_str: &str, to_base: u32) -> String {
    let start_idx = num_str.rfind('(').unwrap();
    let end_idx = num_str.rfind(')').unwrap();
    let (number_part, base_part) = num_str.split_at(start_idx);
    let from_base = base_part[1..end_idx - start_idx].parse::<u32>().unwrap();
    let decimal_value:u32  = u32::from_str_radix(number_part.trim(), from_base).unwrap();
    convert_to_base(decimal_value, to_base)
}


/// change the number to the specified base
fn convert_to_base(mut decimal_value: u32, base: u32) -> String {
    let mut result = String::new();
    let digits = "0123456789abcdef"; // 支持最多16进制的字符集

    while decimal_value > 0 {
        let remainder = decimal_value % base;
        result.insert(0, digits.chars().nth(remainder as usize).unwrap());
        decimal_value /= base;
    }

    if result.is_empty() {
        result.push('0'); // 处理输入为0的情况
    }

    result
}
